home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / dviware / kane / prtpage_p.h < prev    next >
Text File  |  1990-10-01  |  8KB  |  308 lines

  1.  
  2. Date:        20-MAR-1989 17:20:43 GMT
  3. From:        PHYOKANE@CS8700.UCG.IE
  4. To:        abbottp@ASTON.AC.UK
  5. Subject:        file prtpage_p.h
  6. sender:     hea"phyokane@cs8700.ucg.ie"  <phyokane@cs8700.ucg.ie>
  7.  
  8. /* -*-C-*- prtpage.h */
  9. /*-->prtpage*/
  10. /**********************************************************************/
  11. /****************************** prtpage *******************************/
  12. /**********************************************************************/
  13.  
  14. void
  15. prtpage(bytepos)        /* print page whose BOP is at bytepos */
  16. long bytepos;
  17.  
  18. {
  19.     struct stack_entry
  20.     {
  21.     INT32 h;
  22.     COORDINATE hh;
  23.     INT32 v;
  24.     COORDINATE vv;
  25.     INT32 w, x, y, z;    /* what's on stack */
  26.     };
  27.     register BYTE command;  /* current command                */
  28.     register INT16 i;        /* command parameter; loop index        */
  29.     char tc;            /* temporary character            */
  30.     UNSIGN32 ht_rule;        /* rule height                              */
  31.     UNSIGN32 wd_rule;        /* rule width                               */
  32.     INT32 k,m;            /* temporary parameter            */
  33.     INT16 page_number;      /* TeX's \count0 parameter                  */
  34.     BOOLEAN seen_bop;        /* flag for noting processing of BOP    */
  35.     register INT16 sp;        /* stack pointer                */
  36.     struct stack_entry stack[STACKSIZE];    /* stack            */
  37.     char specstr[MAXSPECIAL+1];        /* \special{} string        */
  38.     INT32 w;            /* current horizontal spacing        */
  39.     INT32 x;            /* current horizontal spacing        */
  40.     INT32 y;            /* current vertical spacing            */
  41.     INT32 z;            /* current vertical spacing            */
  42.  
  43. /***********************************************************************
  44. Process all commands  between the  BOP at bytepos  and the  next BOP  or
  45. POST.  The page is  printed when the  EOP is met,  but font changes  can
  46. also happen between EOP and BOP, so we have to keep going after EOP.
  47. ***********************************************************************/
  48.  
  49. /*    (void) checkpage(bytepos); */
  50.  
  51.     seen_bop = FALSE;            /* this is first time through */
  52.     (void) FSEEK(dvifp,bytepos,0);    /* start at the desired position */
  53.  
  54.     for (;;)    /* "infinite" loop - exits when POST or second BOP met */
  55.     {
  56. #if    BBNBITGRAPH
  57.     /* If the test here on every byte proves to carry objectionable
  58.        overhead, it can be moved into the default, PUTx, and SETx
  59.        command sections. The goal is to give the user instant
  60.        response in page screen positioning, without having to wait
  61.        for the entire screen to be painted when it is just going
  62.        to be moved anyway.  This is the sort of display algorithm
  63.        that EMACS uses. */
  64.     if (kbinput() > 0)    /* user has typed something */
  65.         command = EOP;    /* so set for end-of-page action */
  66.     else
  67. #endif
  68.     command = (BYTE)nosignex(dvifp,(BYTE)1);
  69.     switch (command)
  70.     {
  71.  
  72.     case SET1:
  73.     case SET2:
  74.     case SET3:
  75.     case SET4:
  76.         (void)setchar((BYTE)nosignex(dvifp,(BYTE)(command-SET1+1)),TRUE);
  77.         break;
  78.  
  79.     case SET_RULE:
  80.         ht_rule = nosignex(dvifp,(BYTE)4);
  81.         wd_rule = nosignex(dvifp,(BYTE)4);
  82.         (void)setrule(ht_rule,wd_rule,TRUE);
  83.         break;
  84.  
  85.     case PUT1:
  86.     case PUT2:
  87.     case PUT3:
  88.     case PUT4:
  89.         (void)setchar((BYTE)nosignex(dvifp,(BYTE)(command-PUT1+1)),FALSE);
  90.         break;
  91.  
  92.     case PUT_RULE:
  93.         ht_rule = nosignex(dvifp,(BYTE)4);
  94.         wd_rule = nosignex(dvifp,(BYTE)4);
  95.         (void)setrule(ht_rule,wd_rule,FALSE);
  96.         break;
  97.  
  98.     case NOP:
  99.         break;
  100.  
  101.     case BOP:
  102.         if (seen_bop)
  103.         return;            /* we have been here already */
  104.         seen_bop = TRUE;
  105.  
  106.         for (i=0; i<=9; i++)
  107.         tex_counter[i] = (INT32)signex(dvifp,(BYTE)4);
  108.  
  109.             page_number = (INT16)tex_counter[0];
  110. #if    BBNBITGRAPH
  111.         (void)bopact();        /* display menu at top of page */
  112. #else /* not BBNBITGRAPH */
  113.  
  114. #if    (CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT)
  115. #else /* NOT (CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) */
  116.         (void)clrbmap();
  117. #endif /* (CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) */
  118.  
  119.         if (!quiet)
  120.           { (void)fprintf(stderr,"{%s}",tctos()); /* TeX page counters */
  121.         fflush(stderr);
  122.           }
  123.         (void) nosignex(dvifp,(BYTE)4);    /* skip prev. page ptr */
  124. #endif /* BBNBITGRAPH */
  125.  
  126.         h = v = w = x = y = z = 0;
  127.         hh = lmargin;
  128.         vv = tmargin;
  129.         sp = 0;
  130.         fontptr = (struct font_entry*)NULL;
  131.         break;
  132.  
  133.     case EOP:
  134.  
  135. #if    (BBNBITGRAPH | CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT)
  136.         (void)eopact();
  137. #else
  138.         (void)prtbmap();
  139. #endif /* (BBNBITGRAPH | CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) */
  140.  
  141.         return;
  142.  
  143.     case PUSH:
  144.         if (sp >= STACKSIZE)
  145.         (void)fatal("prtpage():  stack overflow");
  146.         stack[sp].h = h;
  147.         stack[sp].hh = hh;
  148.         stack[sp].v = v;
  149.         stack[sp].vv = vv;
  150.         stack[sp].w = w;
  151.         stack[sp].x = x;
  152.         stack[sp].y = y;
  153.         stack[sp].z = z;
  154.         sp++;
  155.         break;
  156.  
  157.     case POP:
  158.         --sp;
  159.         if (sp < 0)
  160.         (void)fatal("prtpage():  stack underflow");
  161.         h = stack[sp].h;
  162.         hh = stack[sp].hh;
  163.         v = stack[sp].v;
  164.         vv = stack[sp].vv;
  165.         w = stack[sp].w;
  166.         x = stack[sp].x;
  167.         y = stack[sp].y;
  168.         z = stack[sp].z;
  169.         break;
  170.  
  171.     case RIGHT1:
  172.     case RIGHT2:
  173.     case RIGHT3:
  174.     case RIGHT4:
  175.         (void)moveover(signex(dvifp,(BYTE)(command-RIGHT1+1)));
  176.         break;
  177.  
  178.     case W0:
  179.         (void)moveover(w);
  180.         break;
  181.  
  182.     case W1:
  183.     case W2:
  184.     case W3:
  185.     case W4:
  186.         w = (INT32)signex(dvifp,(BYTE)(command-W1+1));
  187.         (void)moveover(w);
  188.         break;
  189.  
  190.     case X0:
  191.         (void)moveover(x);
  192.         break;
  193.  
  194.     case X1:
  195.     case X2:
  196.     case X3:
  197.     case X4:
  198.         x = (INT32)signex(dvifp,(BYTE)(command-X1+1));
  199.         (void)moveover(x);
  200.         break;
  201.  
  202.     case DOWN1:
  203.     case DOWN2:
  204.     case DOWN3:
  205.     case DOWN4:
  206.         (void)movedown(signex(dvifp,(BYTE)(command-DOWN1+1)));
  207.         break;
  208.  
  209.     case Y0:
  210.         (void)movedown(y);
  211.         break;
  212.  
  213.     case Y1:
  214.     case Y2:
  215.     case Y3:
  216.     case Y4:
  217.         y = signex(dvifp,(BYTE)(command-Y1+1));
  218.         (void)movedown(y);
  219.         break;
  220.  
  221.     case Z0:
  222.         (void)movedown(z);
  223.         break;
  224.  
  225.     case Z1:
  226.     case Z2:
  227.     case Z3:
  228.     case Z4:
  229.         z = signex(dvifp,(BYTE)(command-Z1+1));
  230.         (void)movedown(z);
  231.         break;
  232.  
  233.     case FNT1:
  234.     case FNT2:
  235.     case FNT3:
  236.     case FNT4:
  237.         (void)setfntnm((INT32)nosignex(dvifp,
  238.         (BYTE)(command-FNT1+1)));
  239.         break;
  240.  
  241.     case XXX1:
  242.     case XXX2:
  243.     case XXX3:
  244.     case XXX4:
  245.         k = (INT32)nosignex(dvifp,(BYTE)(command-XXX1+1));
  246.         if (k > MAXSPECIAL)
  247.         {
  248.         (void)sprintf(message,
  249.             "prtpage():  \\special{} string of %d characters longer \
  250. than DVI driver limit of %d -- truncated.",
  251.         k,MAXSPECIAL);
  252.         (void)warning(message);
  253.         }
  254.         m = 0;
  255.         while (k--)
  256.         {
  257.          tc = (char)nosignex(dvifp,(BYTE)1);
  258.          if (m < MAXSPECIAL)
  259.              specstr[m++] = tc;
  260.         }
  261.         specstr[m] = '\0';
  262.          (void) special(specstr);
  263.         break;
  264.  
  265.     case FNT_DEF1:
  266.     case FNT_DEF2:
  267.     case FNT_DEF3:
  268.     case FNT_DEF4:
  269.         (void)skipfont ((INT32) nosignex(dvifp,
  270.             (BYTE)(command-FNT_DEF1+1)));
  271.         break;
  272.  
  273.     case PRE:
  274.         (void)fatal("prtpage():  PRE occurs within file");
  275.         break;
  276.  
  277.     case POST:
  278.         (void)devterm();        /* terminate device output */
  279.         (void)dviterm();        /* terminate DVI file processing */
  280.         (void)alldone();        /* this will never return */
  281.         break;
  282.  
  283.     case POST_POST:
  284.         (void)fatal("prtpage():  POST_POST with no preceding POST");
  285.         break;
  286.  
  287.     default:
  288.         if (command >= FONT_00 && command <= FONT_63)
  289.         (void)setfntnm((INT32)(command - FONT_00));
  290.         else if (command >= SETC_000 && command <= SETC_127)
  291.  
  292. #if    (HPJETPLUS | POSTSCRIPT | IMPRESS | CANON_A2)
  293.         (void)setstr((BYTE)command); /* this sets several chars */
  294. #else
  295.         (void)setchar((BYTE)(command-SETC_000), TRUE);
  296. #endif /* (HPJETPLUS | POSTSCRIPT | IMPRESS | CANON_A2) */
  297.  
  298.         else
  299.         {
  300.         (void)sprintf(message,"prtpage():  %d is an undefined command",
  301.             command);
  302.         (void)fatal(message);
  303.         }
  304.         break;
  305.     }
  306.     }
  307. }
  308.